package com.template.app.dao.impl;

import java.io.Serializable;

import org.springframework.dao.support.DataAccessUtils;
import org.springframework.stereotype.Repository;

import com.template.app.dao.GenericDao;
import com.template.app.support.DaoSupport;

@Repository
public class GenericDaoImpl extends DaoSupport implements GenericDao {
	
	public boolean exists(Class<?> clazz, Serializable id) {
		return DataAccessUtils.intResult(getHibernateTemplate().find(
				"select count(*) from " + clazz.getSimpleName() + " where id = ?", id)) > 0;
	}

	public <T> T get(Class<T> clazz, Serializable id) {
		return getHibernateTemplate().get(clazz, id);
	}
	
	public <T> T load(Class<T> clazz, Serializable id) {
		return getHibernateTemplate().load(clazz, id);
	}

}
